#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
 #include <unistd.h>
#define _FILE_NAME_PORMAT_ "%s/linux_api_pro/local_api/daemon/log/mydaemon.%ld"
//通过nohup ./a.out &
int main(int argc, char const *argv[])
{
        char strFilename[256] = {0};
        while (1){
                memset(strFilename,0x00,sizeof(strFilename));
                sprintf(strFilename, _FILE_NAME_PORMAT_,getenv("HOME"),time(NULL));
                int fd = open(strFilename,O_RDONLY|O_CREAT,0664);
                if(fd < 0){
                        perror("open err");
                        exit(1);
                }
                close(fd);
                sleep(5);
        }
        return 0;
}